package com.ticket.sass.admin.controller;


import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.ticket.sass.admin.annotation.Loggable;
import com.ticket.sass.admin.annotation.Module;
import com.ticket.sass.admin.business.impl.FilmBusinessImpl;
import com.ticket.sass.admin.dto.input.film.FilmListInput;
import com.ticket.sass.admin.dto.output.film.FilmListOutput;
import com.ticket.sass.admin.model.PageModel;
import com.ticket.sass.admin.model.ResultModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ywb
 * @since 2024-03-07
 */
@RestController
@AllArgsConstructor
@ApiSupport(order = 3)
@Api(tags = {"影片数据-模块"})
@RequestMapping("/films")
public class FilmController {
    final FilmBusinessImpl filmBusiness;
    
    @ApiOperation("列表")
    @GetMapping
    public ResultModel<PageModel<FilmListOutput>> list(
        @Valid FilmListInput input
    ) {
        return ResultModel.success(
            filmBusiness.list(input)
        );
    }
    
    @PostMapping("/sync")
    @ApiOperation("同步影片")
    @Loggable(module = Module.FILM, desc = "同步影片")
    public ResultModel<String> sync() {
        filmBusiness.syncFilm();
        return ResultModel.success();
    }
}
